package com.shopReduce.sql;

import org.apache.commons.lang.StringUtils;

import com.shopReduce.bean.ReduceProgramme;
import com.shopReduce.bean.ShopReduce;

public class ShopReduceBuilder {
	public String list(ShopReduce search) {
		StringBuilder sql = new StringBuilder("select * from sys_reduce_programme where 1=1");
		if(StringUtils.isNotBlank(search.getReduceId())) {
			sql.append(" and reduceId=#{reduceId}");
		}
		if(StringUtils.isNotBlank(search.getId())) {
			sql.append(" and id=#{id}");
		}
		if(StringUtils.isNotBlank(search.getShopId())) {
			sql.append(" and shopId=#{shopId}");
		}
		sql.append(" limit #{start},#{row}");
		return sql.toString();
	}
	public String listCount(ShopReduce search) {
		StringBuilder sql = new StringBuilder("select count(1) from sys_reduce_programme where 1=1");
		if(StringUtils.isNotBlank(search.getReduceId())) {
			sql.append(" and reduceId=#{reduceId}");
		}
		if(StringUtils.isNotBlank(search.getId())) {
			sql.append(" and id=#{id}");
		}
		if(StringUtils.isNotBlank(search.getShopId())) {
			sql.append(" and shopId=#{shopId}");
		}
		return sql.toString();
	}
}
